Stop using stack-allocated snapshots
authorMatthias Clasen <mclasen@redhat.com>
Sun, 11 Mar 2018 02:14:09 +0000 (21:14 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sun, 11 Mar 2018 05:31:44 +0000 (00:31 -0500)
Use the new/free api instead of init/finish
for GtkSnapshot.

gtk/gtkcssimage.c
gtk/gtkiconview.c
gtk/gtkmagnifier.c
gtk/gtkoverlay.c
gtk/gtkstack.c
gtk/gtktreeview.c
gtk/gtkwidget.c

index 665ef93c47c5297f1fe51224bcd9873fdfac452d..6d0f44980342860e990ffb2129209fe8a4629c81 100644 (file)
@@ -219,7 +219,7 @@ _gtk_css_image_draw (GtkCssImage        *image,
                      double              width,
                      double              height)
 {
-  GtkSnapshot snapshot;
+  GtkSnapshot *snapshot;
   GskRenderNode *node;
   cairo_region_t *clip;
 
@@ -231,9 +231,9 @@ _gtk_css_image_draw (GtkCssImage        *image,
   cairo_save (cr);
 
   clip = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 0, 0, width, height });
-  gtk_snapshot_init (&snapshot, NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
-  gtk_css_image_snapshot (image, &snapshot, width, height);
-  node = gtk_snapshot_finish (&snapshot);
+  snapshot = gtk_snapshot_new (NULL, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (image));
+  gtk_css_image_snapshot (image, snapshot, width, height);
+  node = gtk_snapshot_free_to_node (snapshot);
 
   if (node != NULL)
     {
index 6ffbd1d5238b2c8f8d524a7e46b72aa26ec15a8d..e03640344ac2022dbae1c347e2ad2d1991db3df2 100644 (file)
@@ -6689,7 +6689,7 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
                                GtkTreePath *path)
 {
   GtkWidget *widget;
-  GtkSnapshot snapshot;
+  GtkSnapshot *snapshot;
   GskRenderNode *node;
   cairo_t *cr;
   cairo_surface_t *surface;
@@ -6724,15 +6724,15 @@ gtk_icon_view_create_drag_icon (GtkIconView *icon_view,
                                                        rect.width,
                                                        rect.height);
 
-          gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "IconView DragIcon");
-         gtk_icon_view_snapshot_item (icon_view, &snapshot, item, 
-                                       icon_view->priv->item_padding,
-                                       icon_view->priv->item_padding,
-                                       FALSE);
-          node = gtk_snapshot_finish (&snapshot);
+    snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "IconView DragIcon");
+         gtk_icon_view_snapshot_item (icon_view, snapshot, item,
+                                 icon_view->priv->item_padding,
+                                 icon_view->priv->item_padding,
+                                 FALSE);
+    node = gtk_snapshot_free_to_node (snapshot);
 
          cr = cairo_create (surface);
-          gsk_render_node_draw (node, cr);
+    gsk_render_node_draw (node, cr);
          cairo_destroy (cr);
 
          return surface;
index 7d09b10a98cc37b63ba22950ca70da5dd737520f..cc4e85081d828e56c39a5f45ac0032bd97c35c6d 100644 (file)
@@ -103,7 +103,7 @@ gtk_magnifier_snapshot (GtkWidget   *widget,
 {
   GtkMagnifier *magnifier = GTK_MAGNIFIER (widget);
   GtkMagnifierPrivate *priv = _gtk_magnifier_get_instance_private (magnifier);
-  GtkSnapshot inspected_snapshot;
+  GtkSnapshot *inspected_snapshot;
   GskRenderNode *inspected_node;
   graphene_matrix_t transform;
 
@@ -115,14 +115,13 @@ gtk_magnifier_snapshot (GtkWidget   *widget,
 
   g_signal_handler_block (priv->inspected, priv->draw_handler);
 
-  gtk_snapshot_init (&inspected_snapshot,
-                     gtk_snapshot_get_renderer (snapshot),
-                     snapshot->record_names,
-                     NULL,
-                     "MagnifierSnapshot");
+  inspected_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
+                                         snapshot->record_names,
+                                         NULL,
+                                         "MagnifierSnapshot");
 
-  gtk_widget_snapshot (priv->inspected, &inspected_snapshot);
-  inspected_node = gtk_snapshot_finish (&inspected_snapshot);
+  gtk_widget_snapshot (priv->inspected, inspected_snapshot);
+  inspected_node = gtk_snapshot_free_to_node (inspected_snapshot);
 
   if (inspected_node != NULL)
     {
index 3dc65aca77d37838b9407d59060f0a6fbaafa253..90a930799b1b5bff173ae93268013254034792d0 100644 (file)
@@ -673,17 +673,16 @@ gtk_overlay_snapshot (GtkWidget   *widget,
 
           if (main_widget_node == NULL)
             {
-              GtkSnapshot child_snapshot;
-
-              gtk_snapshot_init (&child_snapshot,
-                                 gtk_snapshot_get_renderer (snapshot),
-                                 snapshot->record_names,
-                                 NULL,
-                                 "OverlayCaptureMainChild");
-              gtk_snapshot_offset (&child_snapshot, main_alloc.x, main_alloc.y);
-              gtk_widget_snapshot (main_widget, &child_snapshot);
-              gtk_snapshot_offset (&child_snapshot, -main_alloc.x, -main_alloc.y);
-              main_widget_node = gtk_snapshot_finish (&child_snapshot);
+              GtkSnapshot *child_snapshot;
+
+              child_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
+                                                 snapshot->record_names,
+                                                 NULL,
+                                                 "OverlayCaptureMainChild");
+              gtk_snapshot_offset (child_snapshot, main_alloc.x, main_alloc.y);
+              gtk_widget_snapshot (main_widget, child_snapshot);
+              gtk_snapshot_offset (child_snapshot, -main_alloc.x, -main_alloc.y);
+              main_widget_node = gtk_snapshot_free_to_node (child_snapshot);
               graphene_matrix_init_translate (&translate, &GRAPHENE_POINT3D_INIT (main_alloc.x,main_alloc.y, 0));
             }
 
index b501b77edb720bafb5462bdffcae8fbbd2a5d155..172801e19431b91364adb358668e28761c667f7c 100644 (file)
@@ -1952,17 +1952,16 @@ gtk_stack_snapshot (GtkWidget   *widget,
           if (priv->last_visible_node == NULL &&
               priv->last_visible_child != NULL)
             {
-              GtkSnapshot last_visible_snapshot;
+              GtkSnapshot *last_visible_snapshot;
 
               gtk_widget_get_allocation (priv->last_visible_child->widget,
                                          &priv->last_visible_surface_allocation);
-              gtk_snapshot_init (&last_visible_snapshot,
-                                 gtk_snapshot_get_renderer (snapshot),
-                                 snapshot->record_names,
-                                 NULL,
-                                 "StackCaptureLastVisibleChild");
-              gtk_widget_snapshot (priv->last_visible_child->widget, &last_visible_snapshot);
-              priv->last_visible_node = gtk_snapshot_finish (&last_visible_snapshot);
+              last_visible_snapshot = gtk_snapshot_new (gtk_snapshot_get_renderer (snapshot),
+                                                        snapshot->record_names,
+                                                        NULL,
+                                                        "StackCaptureLastVisibleChild");
+              gtk_widget_snapshot (priv->last_visible_child->widget, last_visible_snapshot);
+              priv->last_visible_node = gtk_snapshot_free_to_node (last_visible_snapshot);
             }
 
           gtk_snapshot_push_clip (snapshot,
index 1670f1a0c8e4c828b92d12d62f2a536b90ab5d0f..e3657c9d92f4e930bde643e3004a5fe53ee5d320 100644 (file)
@@ -13821,7 +13821,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView  *tree_view,
   GList *list;
   GdkRectangle background_area;
   GtkWidget *widget;
-  GtkSnapshot snapshot;
+  GtkSnapshot *snapshot;
   GskRenderNode *rendernode;
   gint depth;
   /* start drawing inside the black outline */
@@ -13871,9 +13871,9 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView  *tree_view,
                                                bin_window_width + 2,
                                                background_area.height + 2);
 
-  gtk_snapshot_init (&snapshot, NULL, FALSE, NULL, "TreeView DragIcon");
+  snapshot = gtk_snapshot_new (NULL, FALSE, NULL, "TreeView DragIcon");
 
-  gtk_snapshot_render_background (&snapshot, context,
+  gtk_snapshot_render_background (snapshot, context,
                                   0, 0,
                                   bin_window_width + 2,
                                   background_area.height + 2);
@@ -13924,7 +13924,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView  *tree_view,
               gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
 
               gtk_style_context_get_color (context, &color);
-              gtk_snapshot_append_color (&snapshot,
+              gtk_snapshot_append_color (snapshot,
                                          &color, 
                                          &GRAPHENE_RECT_INIT(
                                              cell_area.x,
@@ -13939,7 +13939,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView  *tree_view,
          else
             {
               gtk_tree_view_column_cell_snapshot (column,
-                                                  &snapshot,
+                                                  snapshot,
                                                   &background_area,
                                                   &cell_area,
                                                   0, FALSE);
@@ -13948,7 +13948,7 @@ gtk_tree_view_create_row_drag_icon (GtkTreeView  *tree_view,
       cell_offset += gtk_tree_view_column_get_width (column);
     }
 
-  rendernode = gtk_snapshot_finish (&snapshot);
+  rendernode = gtk_snapshot_free_to_node (snapshot);
 
   cr = cairo_create (surface);
 
index 65bcf6adf5470665defebf716c5d31b2bf233f13..e78f66272dc29fe5a2c44c1178e7c73ad4695144 100644 (file)
@@ -5459,7 +5459,7 @@ gtk_widget_draw_internal (GtkWidget *widget,
       if (mode == RENDER_SNAPSHOT)
         {
           GskRenderer *renderer = gtk_widget_get_renderer (widget);
-          GtkSnapshot snapshot;
+          GtkSnapshot *snapshot;
           cairo_region_t *clip;
           GskRenderNode *node;
 
@@ -5468,9 +5468,9 @@ gtk_widget_draw_internal (GtkWidget *widget,
                                                 widget->priv->clip.y - widget->priv->allocation.y,
                                                 widget->priv->clip.width,
                                                 widget->priv->clip.height});
-          gtk_snapshot_init (&snapshot, renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
-          gtk_widget_snapshot (widget, &snapshot);
-          node = gtk_snapshot_finish (&snapshot);
+          snapshot = gtk_snapshot_new (renderer, FALSE, clip, "Fallback<%s>", G_OBJECT_TYPE_NAME (widget));
+          gtk_widget_snapshot (widget, snapshot);
+          node = gtk_snapshot_free_to_node (snapshot);
           if (node != NULL)
             {
               gsk_render_node_draw (node, cr);
@@ -13981,7 +13981,7 @@ gtk_widget_render (GtkWidget            *widget,
                    const cairo_region_t *region)
 {
   GdkDrawingContext *context;
-  GtkSnapshot snapshot;
+  GtkSnapshot *snapshot;
   GskRenderer *renderer;
   GskRenderNode *root;
   cairo_region_t *clip;
@@ -13997,14 +13997,13 @@ gtk_widget_render (GtkWidget            *widget,
   context = gsk_renderer_begin_draw_frame (renderer, region);
   clip = gdk_drawing_context_get_clip (context);
 
-  gtk_snapshot_init (&snapshot,
-                     renderer,
-                     should_record_names (widget, renderer),
-                     clip,
-                     "Render<%s>", G_OBJECT_TYPE_NAME (widget));
+  snapshot = gtk_snapshot_new (renderer,
+                               should_record_names (widget, renderer),
+                               clip,
+                               "Render<%s>", G_OBJECT_TYPE_NAME (widget));
   cairo_region_destroy (clip);
-  gtk_widget_snapshot (widget, &snapshot);
-  root = gtk_snapshot_finish (&snapshot);
+  gtk_widget_snapshot (widget, snapshot);
+  root = gtk_snapshot_free_to_node (snapshot);
   if (root != NULL)
     {
       gtk_inspector_record_render (widget,